package com.jy.rhin.infra.repo.document.submission.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.jy.rhin.infra.repo.document.submission.po.DocumentSubmissionSetPO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author dhl
 * @date 2022/6/1
 * @Description
 */
@Mapper
@Repository
public interface DocumentSubmissionSetMapper extends BaseMapper<DocumentSubmissionSetPO> {

    /**
     * 列表查询
     * @param queryWrapper
     * @return
     */
    @Select("SELECT distinct a.id,                                                \n" +
            "       a.home_community_id AS homeCommunityId,                       \n" +
            "       a.source_id         AS sourceId,                              \n" +
            "       a.unique_id         AS uniqueId,                              \n" +
            "       a.submission_time   AS submissionTime,                        \n" +
            "       a.json_text         AS jsonText,                              \n" +
            "       a.content_type_code AS contentTypeCode,                       \n" +
            "       a.create_time       AS createTime                             \n" +
            "FROM t_document_submission_set a                                     \n" +
            "${ew.customSqlSegment}                           ")
    List<DocumentSubmissionSetPO> querySubmissionSetListByCoding(@Param(Constants.WRAPPER) QueryWrapper<DocumentSubmissionSetPO> queryWrapper);

    /**
     * 列表查询
     * @param queryWrapper
     * @return
     */
    @Select("SELECT distinct a.id,                                       \n" +
            "       a.home_community_id AS homeCommunityId,              \n" +
            "       a.source_id         AS sourceId,                     \n" +
            "       a.unique_id         AS uniqueId,                     \n" +
            "       a.submission_time   AS submissionTime,               \n" +
            "       a.json_text         AS jsonText,                     \n" +
            "       a.content_type_code AS contentTypeCode,              \n" +
            "       a.create_time       AS createTime                    \n" +
            "FROM t_document_submission_set a left join                  \n" +
            "     t_document_entry b ON a.id = b.submission_id          \n" +
            "${ew.customSqlSegment}                           ")
    List<DocumentSubmissionSetPO> querySubmissionSetListByEntry(@Param(Constants.WRAPPER) QueryWrapper<DocumentSubmissionSetPO> queryWrapper);

}
